home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmigaPlus / Tools / Development / RxMUI / Examples / Tutorial2.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  2004-01-31  |  7.3 KB  |  231 lines

  1. /* This is the base for a never written tutorial */
  2.  
  3. signal on halt
  4. signal on break_c
  5.  
  6. /* init our world */
  7. call Init
  8.  
  9. /* create the application */
  10. call createApp
  11.  
  12. /* open the window */
  13. call set("win","open",1)
  14.  
  15. /* handle the application */
  16. call handleApp
  17.  
  18. /* this point is never reached */
  19. /***********************************************************************/
  20. Init: procedure
  21.     /* add the needed libraries */
  22.     l="rmh.library";if ~show("L",l) then;if ~addlib(l,0,-30) then exit
  23.     if AddLibrary("rxmui.library")~=0 then exit
  24.     call ProgDir()
  25.     return
  26. /***********************************************************************/
  27. handleApp: procedure
  28.     /* this is the standard cycle to handle an application */
  29.     ctrl_C=2**12
  30.     do forever
  31.     call NewHandle("app","h",ctrl_c)
  32.     if and(h.signals,ctrl_c)>0 then exit
  33.     if h.EventFlag then
  34.         select
  35.             when h.event="QUIT" then exit
  36.             otherwise interpret h.event
  37.         end
  38.     end
  39.     /* this point is never reached */
  40. /***********************************************************************/
  41. createApp: procedure
  42.  
  43.     /* first of all the let's define the application object */
  44.     app.Title="Tutorial2"
  45.     app.Version="$VER: Tutorial2 1.1 (25.1.2002)"
  46.     app.Copyright="Copyright 1999-2002 by Alfonso Ranieri"
  47.     app.Author="Alfonso Ranieri"
  48.     app.Description="Just a little example"
  49.     app.Base="EXAMPLE"
  50.     app.DiskObject="PROGDIR:tutorial2"
  51.  
  52.     /* this is the menu strip */
  53.     app.menustrip="strip"
  54.      strip.class="Menustrip"
  55.      strip.0="mproject"
  56.       mproject.Title="Project"
  57.       mproject.class="menu"
  58.        mproject.0=menuitem("mabout","?\About...")
  59.        mproject.1=menuitem("maboutrxmui","X\About RxMUI...")
  60.        mproject.2=menuitem("maboutmui","!\About MUI...")
  61.        mproject.3=menuitem("","BAR")
  62.        mproject.4=menuitem("mhide","H\Hide")
  63.        mproject.5=menuitem("","BAR")
  64.        mproject.6=menuitem("mquit","Q\Quit")
  65.  
  66.      /* this is the main (and only) window */
  67.     app.SubWindow="win"
  68.      win.ID="MAIN"
  69.      win.Title="A Tutorial"
  70.  
  71.       /* the window contents */
  72.      win.Contents="mgroup"
  73.  
  74.       mgroup.0="dg"
  75.        dg.Class="group"
  76.        dg.Frame="group"
  77.        dg.Background="GroupBack"
  78.        dg.Columns=2
  79.  
  80.         dg.0=label("_Name");
  81.          name.CycleChain=1
  82.          name.AdvanceOnCR=1
  83.         dg.1=String("name",'n')
  84.  
  85.         dg.2=Label("_Age");
  86.          age.CycleChain=1
  87.         dg.3=MakeObj(,"HLeft",MakeObj("Age","NumericButton","a",0,150,30))
  88.  
  89.         dg.4=Label("_Sex","Double")
  90.          sex.CycleChain=1
  91.         dg.5=MakeObj(,"HLeft",MakeObj("Sex","Radio","Male|Female","_Sex",,1))
  92.  
  93.         dg.6=Label("_Knowledge");
  94.          known.CycleChain=1
  95.         dg.7=MakeObj("known","Cycle","Novice|Average|Good|Expert","_Knowledge")
  96.  
  97.         dg.8=Label("Language(s)")
  98.         dg.9="lg"
  99.          lg.class="group"
  100.          lg.horiz=1
  101.            BASIC.CycleChain=1
  102.           lg.0=Checkmark("BASIC",,'b')
  103.           lg.1=Label("_Basic")
  104.           lg.2=HSPace()
  105.            ARexx.CycleChain=1
  106.           lg.3=Checkmark("ARexx",,'x')
  107.           lg.4=Label("ARe_xx")
  108.            C.CycleChain=1
  109.           lg.5=HSPace()
  110.           lg.6=Checkmark("C",,'c')
  111.           lg.7=Label("_C")
  112.           lg.8=HSPace()
  113.            ASM.CycleChain=1
  114.           lg.9=Checkmark("ASM",,'m')
  115.           lg.10=Label("AS_M")
  116.           lg.11=hvspace()
  117.  
  118.       /* to use a crawling you must set its height
  119.          as large as the first object */
  120.       mgroup.1="cr"
  121.        cr.class="crawling"
  122.        cr.Frame="Text"
  123.        cr.Background="TextBack"
  124.        cr.FixHeightTxt="0a"x
  125.  
  126.         /* this is the first object */
  127.         parse value(RxMUIOpt("Ask")) with . v date .
  128.         cr.0="t0"
  129.          t0.class="text"
  130.          t0.contents=ParseText("%c%bRxMUI%n" v date "\n
  131. Copyright 1999-2002 by Alfonso Ranieri")
  132.  
  133.         /* this is the second object (you could insert other) */
  134.         cr.1="t1"
  135.          t1.class="text"
  136.          t1.contents=ParseText("%c\n
  137. Please fill this registration form\n
  138. and send to <alforan@tin.it>\n
  139. You will receive a RxMUI ver. 3 key file!\n")
  140.  
  141.         /* repeating the first object at the end makes
  142.            the crawling smoother */
  143.         cr.2="t2"
  144.          t2.class="text"
  145.          t2.contents=t0.contents
  146.  
  147.       mgroup.2="bg"
  148.        bg.class="group"
  149.        bg.columns=3
  150.          reset.CycleChain=1
  151.         bg.0=Button("reset","_Reset Form")
  152.          done.CycleChain=1
  153.         bg.1=Button("done","_Done")
  154.          cancel.CycleChain=1
  155.         bg.2=Button("cancel","Cance_l")
  156.  
  157.     /* create all */
  158.     call NewObj("APPLICATION","APP")
  159.  
  160.     /* window close gadget means quit */
  161.     call Notify("win","CloseRequest",1,"app","ReturnID","QUIT")
  162.  
  163.     /* reset pressed -> reset all to defaults */
  164.     call Notify("reset","pressed",0,"app","Return","call reset")
  165.  
  166.     /* done pressed -> print all */
  167.     call Notify("done","pressed",0,"app","Return","call print")
  168.  
  169.     /* cancel pressed -> exit */
  170.     call Notify("cancel","pressed",0,"app","returnid","quit")
  171.  
  172.     /* about menuitem means show the automatic about requester */
  173.     call Notify("mabout","menutrigger","Everytime","app","about","win")
  174.  
  175.     /* aboutrxmui menuitem means show the rxmui about requester */
  176.     call Notify("maboutrxmui","menutrigger","everytime","app","aboutrxmui","win")
  177.  
  178.     /* aboutmui menuitem means show the about MUI window */
  179.     call Notify("maboutmui","menutrigger","everytime","app","aboutmui","win")
  180.  
  181.     /* hide menuitem means hide all windows (just one here) */
  182.     call Notify("mhide","menutrigger","everytime","app","set","iconified",1)
  183.  
  184.     /* quit menu item means quit */
  185.     call Notify("mquit","menutrigger","everytime","app","returnid","quit")
  186.  
  187.     call set("win","activeobject","done")
  188.     return
  189. /***********************************************************************/
  190. halt:
  191. break_c:
  192.     exit
  193. /**************************************************************************/
  194. reset: procedure
  195.     set.0="name";  set.0.attr="Contents"; set.0.value=""
  196.     set.1="age";   set.1.attr="Value";    set.1.value=30
  197.     set.2="Sex";   set.2.attr="Active";   set.2.value=0
  198.     set.3="known"; set.3.attr="Active";   set.3.value=0
  199.     set.4="BASIC"; set.4.attr="Selected"; set.4.value=0
  200.     set.5="ARexx"; set.5.attr="Selected"; set.5.value=0
  201.     set.6="C";     set.6.attr="Selected"; set.6.value=0
  202.     set.7="ASM";   set.7.attr="Selected"; set.7.value=0
  203.     call MultiSetAttr("set")
  204.     return
  205. /**************************************************************************/
  206. print: procedure
  207.     get.0="name";  get.0.attr="Contents"
  208.     get.1="age";   get.1.attr="Value"
  209.     get.2="Sex";   get.2.attr="Active"
  210.     get.3="known"; get.3.attr="Active"
  211.     get.4="BASIC"; get.4.attr="Selected"
  212.     get.5="ARexx"; get.5.attr="Selected"
  213.     get.6="C";     get.6.attr="Selected"
  214.     get.7="ASM";   get.7.attr="Selected"
  215.     call MultiGetAttr("get")
  216.     if get.0.value="" then do
  217.         call set("win","ActiveObject","name")
  218.         return
  219.     end
  220.     say " Name:" get.0.value
  221.     say "  Age:" get.1.value
  222.     say "  Sex:" word("Male Female",get.2.value+1)
  223.     say "Known:" word("Novice Average Good Expert",get.3.value+1)
  224.     say "BASIC:" word("Unknown Known ",get.4.value+1)
  225.     say "ARexx:" word("Unknown Known ",get.5.value+1)
  226.     say "    C:" word("Unknown Known ",get.6.value+1)
  227.     say "  ASM:" word("Unknown Known ",get.7.value+1)
  228.  
  229.     return
  230. /**************************************************************************/
  231.